﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Baitap3
{
    public partial class Employees : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void DataList2_DeleteCommand(object source, DataListCommandEventArgs e)
        {
            int ID = (int)DataList2.DataKeys[e.Item.ItemIndex];
            SqlDataSource2.DeleteParameters["EmployeeID"].DefaultValue = ID.ToString().Trim();
            SqlDataSource2.Delete();
        }

        protected void Repeater1_ItemCommand(object Sender, RepeaterCommandEventArgs e)
        {
            if ((string)e.CommandName == "ViewDetail")
            {
                Session.Add("RepeaterEmpID", (string)e.CommandArgument);
                FormView3.DataBind();
            }
            if ((string)e.CommandName == "Delete")
            {
                RepeaterDataSource.DeleteParameters["EmployeeID"].DefaultValue = (string)e.CommandArgument;
                RepeaterDataSource.Delete();
            }
        }
        //Update Repeater when user deleted, updated, inserted by FormView3
        public void FormView3_ItemInserted(Object sender, FormViewInsertedEventArgs e)
        {
            Repeater1.DataBind();
        }

        public void FormView3_ItemDeleted(Object sender, FormViewDeletedEventArgs e)
        {
            Repeater1.DataBind();
        }

        public void FormView3_ItemUpdated(Object sender, FormViewUpdatedEventArgs e)
        {
            Repeater1.DataBind();
        }
        //Update Datalist when user deleted, updated, inserted by FormView3
        public void FormView2_ItemInserted(Object sender, FormViewInsertedEventArgs e)
        {
            DataList2.DataBind();
        }

        public void FormView2_ItemDeleted(Object sender, FormViewDeletedEventArgs e)
        {
            DataList2.DataBind();
        }

        public void FormView2_ItemUpdated(Object sender, FormViewUpdatedEventArgs e)
        {
            DataList2.DataBind();
        }

    }
}